<?php
/*
 * @Author: Wulala
 * @Date: 2025-01-12 13:22:27
 * @LastEditTime: 2025-01-12 13:38:05
 * @LastEditors: Wulala
 * @Description: 
 * @FilePath: \zhongshelife\application\common\library\Shangfutong.php
 * 可以输入预定的版权声明、个性签名、空行等
 */

namespace app\common\library;

/**
 * 商福通支付
 */
class Shangfutong
{

    protected static $sft_url ='https://pay.rscygroup.com';

    /**
    *统一请求出口
    */
    public static function send($url='',$params=[])
    {
        //业务参数加密
        $postData['appId'] = '2081241219855942';//appId
        $postData['bizData'] = json_encode($params,JSON_UNESCAPED_UNICODE);//数据参数
        $postData['reqId'] = getRandomString(8).time();
        $postData['reqTime'] = date("YmdHis");
        $postData['signType'] = 'MD5';//md5加密
        $postData['version'] = '1.0';
        $createsign = sybAscii($postData);
        $postData['sign'] = md5($createsign);
        $contentType = ["Content-type:application/json"];
        $response = send_post($url, $postData,$contentType);
        $res=json_decode($response,true);

        return $res;
    }

    /**
    *小程序支付
    */
    public static function pay($params=[])
    {
        $url = self::$sft_url."/api/open/payment/ltpay";
        $res=self::send($url,$params);

        return $res;
    }

    /**
    *退款
    */
    public static function refund($params=[])
    {
        $url = self::$sft_url."/api/open/order/refund";
        $res=self::send($url,$params);

        return $res;
    }

    /**
    *进件（api）
    */
    public static function applyment($params=[])
    {
        $url = self::$sft_url."/api/open/applyment/audit";
        $res=self::send($url,$params);

        return $res;
    }


    /**
    *进件（h5）
    */
    public static function applymentH5($params=[])
    {
        $url = self::$sft_url."/api/open/applyment/h5Data";
        $res=self::send($url,$params);

        return $res;
    }


    /**
    *进件数据查询（h5）
    */
    public static function queryApplymentInfo($params=[])
    {
        $url = self::$sft_url."/api/open/applyment/queryApplymentInfo";
        $res=self::send($url,$params);

        return $res;
    }

    /**
    *公众号（h5）支付
    */
    public static function jspay($params=[])
    {
        $url = self::$sft_url."/api/open/payment/jspay";
        $res=self::send($url,$params);

        return $res;
    }
}
